<?php
namespace app\example\loglic;

class Install
{
    //安装MYSQL版回调
    public function mysql()
    {
        \daicuo\Apply::install('index','install');
        
        return true;
    }
    
    //设置首页路由
    private function indexRewrite()
    {
        return model('common/Route','loglic')->index('example/index/index', 'index');
    }
    
    //批量添加初始配置
    public function config()
    {
        config('common.validate_name', false);
        
        return model('common/Config','loglic')->install([
            'title'       => '呆错后台管理框架开发实例',
            'keywords'    => 'DaiCuo,呆错开发实例,后台框架,后台模板',
            'description' => '呆错（DaiCuo）是一款基于ThinkPHP、Bootstrap、Jquery的自适应后台管理框架！',
        ],'example');
    }
    
    //批量定义语言包
    public function lang()
    {
        return true;
    }
    
    //批量写入插件动态字段
    public function field()
    {
        return true;
    }
    
    //批量添加路由伪静态
    public function route()
    {
        return true;
    }
    
    //批量添加用户
    public function user()
    {
        return true;
    }
    
    //批量添加角色（用户组）
    public function role()
    {
        return true;
    }
    
    //批量添加权限
    public function auth()
    {
        return true;
    }
    
    //批量添加后台菜单
    public function menu()
    {
        config('common.validate_name', false);
        
        model('common/Menu','loglic')->install([
            [
                'term_name'   => '实例',
                'term_slug'   => 'example',
                'term_info'   => 'fa-sitemap',
                'term_module' => 'example',
                'term_order'  => 9,
            ],
        ]);
        
        model('common/Menu','loglic')->install([
            [
                'term_name'   => '分类管理',
                'term_slug'   => 'admin/category/index?parent=example&term_module=example',
                'term_info'   => 'fa-list',
                'term_module' => 'example',
                'term_order'  => 8,
            ],
            [
                'term_name'   => '标签管理',
                'term_slug'   => 'admin/tag/index?parent=example&term_module=example',
                'term_info'   => 'fa-tags',
                'term_module' => 'example',
                'term_order'  => 7,
            ],
            [
                'term_name'   => '字段管理',
                'term_slug'   => 'admin/field/index?parent=example&op_module=example',
                'term_info'   => 'fa-cube',
                'term_module' => 'example',
                'term_order'  => 3,
            ],
            [
                'term_name'   => '语言定义',
                'term_slug'   => 'admin/lang/index?parent=example&op_module=example',
                'term_info'   => 'fa-commenting',
                'term_module' => 'example',
                'term_order'  => 2,
            ],
            [
                'term_name'   => '后台菜单',
                'term_slug'   => 'admin/menu/index?parent=example&term_module=example',
                'term_info'   => 'fa-navicon',
                'term_module' => 'example',
                'term_order'  => 1,
            ],
            [
                'term_name'   => '频道配置',
                'term_slug'   => 'example/admin/index',
                'term_info'   => 'fa-code',
                'term_module' => 'example',
                'term_order'  => 0,
            ],
        ],'实例');
        
        return true;
    }
    
    //批量添加前台菜单
    public function navs()
    {
        config('common.validate_name', false);
        
        model('common/Navs','loglic')->install([
            [
                'navs_name'       => '开发实例',
                'navs_url'        => 'example/index/index',
                'navs_type'       => 'navbar',
                'navs_module'     => 'example',
                'navs_order'      => 9,
                'navs_active'     => 'exampleindexindex',
                'navs_target'     => '_self',
            ],
            [
                'navs_name'       => 'DaiCuo分类',
                'navs_url'        => 'example/category/index',
                'navs_type'       => 'link',
                'navs_ico'        => 'fa fa-navicon',
                'navs_module'     => 'example',
                'navs_order'      => 6,
                'navs_active'     => 'examplecategoryindex',
                'navs_target'     => '_self',
            ],
            [
                'navs_name'       => 'DaiCuo标签',
                'navs_url'        => 'example/tag/index',
                'navs_type'       => 'link',
                'navs_ico'        => 'fa fa-tag',
                'navs_module'     => 'example',
                'navs_order'      => 5,
                'navs_active'     => 'exampletagindex',
                'navs_target'     => '_self',
            ],
            [
                'navs_name'       => 'DaiCuo菜单',
                'navs_url'        => 'example/navs/index',
                'navs_type'       => 'link',
                'navs_ico'        => 'fa fa-navicon',
                'navs_module'     => 'example',
                'navs_order'      => 4,
                'navs_active'     => 'examplenavsindex',
                'navs_target'     => '_self',
            ],
            [
                'navs_name'       => 'DaiCuo表格',
                'navs_url'        => 'example/table/index',
                'navs_type'       => 'link',
                'navs_ico'        => 'fa fa-table',
                'navs_module'     => 'example',
                'navs_order'      => 3,
                'navs_active'     => 'exampletableindex',
                'navs_target'     => '_self',
            ],
            [
                'navs_name'       => 'DaiCuo表单',
                'navs_url'        => 'example/form/index',
                'navs_type'       => 'link',
                'navs_ico'        => 'fa fa-html5',
                'navs_module'     => 'example',
                'navs_order'      => 2,
                'navs_active'     => 'exampleformindex',
                'navs_target'     => '_self',
            ],
            [
                'navs_name'       => 'DaiCuo验证码',
                'navs_url'        => 'example/captcha/index',
                'navs_type'       => 'link',
                'navs_ico'        => 'fa fa-image',
                'navs_module'     => 'example',
                'navs_order'      => 1,
                'navs_active'     => 'examplecaptchaindex',
                'navs_target'     => '_self',
            ],
        ]);
        
        return true;
    }
    
    //批量添加初始分类
    public function category()
    {
        return true;
    }
    
    //批量添加初始标签
    public function tag()
    {
        return true;
    }
}